package com.gs.action;

import java.io.IOException;
import java.io.PrintWriter;

import net.sf.json.JSONObject;

import org.apache.struts2.ServletActionContext;

import com.liang.ext.bean.ExtFormBean;
import com.liang.log.Log;
import com.opensymphony.xwork2.ActionSupport;

/**
 * @author pjt
 *
 */
public class BasicAction extends ActionSupport {
	
	
	
	/**
	 * @作用：把数据刷到前台
	 * @param result
	 * @throws IOException
	 */
	protected void writeString(String result) throws IOException{
		ServletActionContext.getResponse().setContentType("text/html");
		PrintWriter out = ServletActionContext.getResponse().getWriter();
		out.write(result);
		out.flush();
		out.close();
	}
	
	/**
	 * 与EXT一起作用写到前台
	 * @param bean
	 * @throws IOException
	 */
	protected void writeExtFormBean(ExtFormBean bean)throws IOException{
		JSONObject json = JSONObject.fromObject(bean);
		Log.info(json.toString());
		writeString(json.toString());
	}
}
